# Contributor: Matt Smith <mcs@darkregion.net>
# Maintainer: Matt Smith <mcs@darkregion.net>
pkgname=py3-docutils
pkgver=0.20.1
pkgrel=2
pkgdesc="Documentation Utilities for Python3"
url="https://pypi.org/project/docutils"
arch="noarch"
license="BSD-2-Clause AND GPL-3.0-or-later AND Python-2.0"
depends="python3"
makedepends="py3-gpep517 py3-setuptools py3-wheel"
checkdepends="py3-pytest"
subpackages="$pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/d/docutils/docutils-$pkgver.tar.gz"
builddir="$srcdir/docutils-$pkgver"

replaces="py-docutils" # Backwards compatibility
provides="py-docutils=$pkgver-r$pkgrel" # Backwards compatibility

build() {
	gpep517 build-wheel --wheel-dir .dist --output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" .dist/*.whl

	# Remove .py extension and add version suffix to executable files.
	local path; for path in "$pkgdir"/usr/bin/*.py; do
		mv "$path" "${path/.py/}"
		ln -sfv "$(basename "${path/.py/}")" "$path"
		ln -sfv "$(basename "${path/.py/}")" "${path/.py/}-3"
	done
}

sha512sums="
a0ddca315d03677003036d6a8052ac96fbd3fcc4508564938ea684d79bedb4d322d83449c7b26e55b19b0aadd6e46ca9ac409bb16279a20f06c70e9c15ef5eb0  docutils-0.20.1.tar.gz
"
